package net.tv90.bfmccore.util.area;

import lombok.Data;
import net.tv90.bfmccore.util.vector.Vector2i;
import net.tv90.bfmccore.util.vector.Vector3i;

@Data
public class CircleArea implements Area{

    private Vector2i center;
    private int radius;
    private int minHeight;
    private int maxHeight;

    public CircleArea(Vector2i center, int radius, int minHeight, int maxHeight) {
        this.center = center;
        this.radius = radius;
        this.minHeight = minHeight;
        this.maxHeight = maxHeight;
    }

    @Override
    public boolean isInArea(Vector3i point3i) {
        if(point3i == null) return false;
        if(point3i.y > maxHeight || point3i.y < minHeight){
            return false;
        }
        int x = point3i.getX();
        int z = point3i.getZ();
        int x1 = center.getX();
        int y1 = center.getY();
        return Math.pow(x - x1, 2) + Math.pow(z - y1, 2) <= radius * radius;
    }
}
